home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Slider 1.0 / Sources / UGrayscaleAppearance.cp < prev    next >
Encoding:
Text File  |  1996-06-19  |  3.0 KB  |  124 lines  |  [TEXT/CWIE]

  1. //
  2. //    UGrayscaleAppearance.cp
  3. //
  4. //    Utilities for supporting the Apple Grayscale Appearance for System 7.5
  5. //
  6. //
  7. //    Copyright © 1996 by James Jennings. All rights reserved.
  8. //
  9.  
  10. // To Check: are these being disposed of?
  11.  
  12. #include "UGrayscaleAppearance.h"
  13.  
  14. void    UGrayscaleAppearance::FrameRect( const Rect &inFrame, 
  15.         EGAColor inTopLeft, EGAColor inBottomRight, EGAColor inCorners)
  16. {    // Draw a frame that gives the "beveled" look.
  17.     // inTopLeft is the color of the top and left edges.
  18.     // inBottomRight is the color of the bottom and right edges.
  19.     // inCorners is the color of the pixels in the bottom-left and top-right corners.
  20.     
  21.     // width and height of the interior of the frame
  22.     Int16 width = inFrame.right - inFrame.left - 2;
  23.     Int16 height = inFrame.bottom - inFrame.top - 2;
  24.     
  25.     Assert_( width >= 0 && height >= 0 );
  26.     
  27.     ::PenSize( 1, 1 );
  28.     
  29.     ::MoveTo( inFrame.left, inFrame.bottom - 1 );
  30.     SetForeColor( inCorners );
  31.     ::Line( 0, 0 );
  32.     
  33.     SetForeColor( inTopLeft );
  34.     ::Move( 0, -1 );
  35.     ::Line( 0, - height );
  36.     ::Line( width, 0 );
  37.     
  38.     SetForeColor( inCorners );
  39.     ::Move( 1, 0 );
  40.     ::Line( 0, 0 );
  41.     
  42.     SetForeColor( inBottomRight );
  43.     ::Move( 0, 1 );
  44.     ::Line( 0, height );
  45.     ::Line( - width, 0 );
  46.     
  47. }
  48.  
  49. void    UGrayscaleAppearance::PrimaryGroupRect( 
  50.         Rect inFrame, EGAColor inTopLeft, EGAColor inBottomRight )
  51. {
  52.     ::PenSize( 1, 1 );
  53.     
  54.     inFrame.top ++;
  55.     inFrame.left ++;
  56.     SetForeColor( inBottomRight );
  57.     ::FrameRect( &inFrame );
  58.     
  59.     ::OffsetRect( &inFrame, -1, -1 );
  60.     SetForeColor( inTopLeft );
  61.     ::FrameRect( &inFrame );
  62.     
  63.     // fill in the corners
  64.     SetForeColor( inBottomRight );
  65.     ::MoveTo( inFrame.left, inFrame.bottom );
  66.     ::Line( 0, 0 );
  67.     
  68.     ::MoveTo( inFrame.right, inFrame.top );
  69.     ::Line( 0, 0 );
  70. }
  71.  
  72. void    CGABaseAttachment::ExecuteSelf( MessageT inMessage, void *ioParam)
  73. {    // Call the correct draw routine depending on the screen depth.
  74.     
  75.     Assert_( ioParam != nil );
  76.     
  77.     StColorState theSavedState;
  78.     
  79.     Rect theFrame = *(Rect *)ioParam;
  80.     
  81.     // The device loop sets the clip rect, so we need to tell it 
  82.     // the rect we plan to draw to.
  83.     Rect clipRect = theFrame;
  84.     AdjustClipRect( clipRect );
  85.     
  86.     StDeviceLoop devices(clipRect);
  87.     Int16 depth;
  88.  
  89.     while (devices.NextDepth(depth)) {
  90.         StColorPenState savePenState;        // Will save and restore pen state
  91.         savePenState.Normalize();
  92.         
  93.         if (depth > 3) {
  94.             DrawColor( theFrame );    // we have at least 16 colors
  95.         } else {
  96.             DrawBlackAndWhite( theFrame );
  97.         }
  98.     }
  99.  
  100. }
  101.  
  102. void    CGAPaneAttachment::DrawColor( Rect &inFrame )
  103. {
  104.     FrameRect( inFrame, ga_Hilite, ga_Shadow, ga_Hilite );
  105.     ::InsetRect( &inFrame, 1, 1 );
  106.     PaintRect( inFrame, ga_Background );
  107. }
  108.  
  109. void    CGADeepPaneAttachment::DrawColor( Rect &inFrame )
  110. {    // The color scheme of a movable modal dialog. (Not counting the black outline.)
  111.     FrameRect( inFrame, ga_2, ga_10, ga_2 );
  112.     ::InsetRect( &inFrame, 1, 1 );
  113.     FrameRect( inFrame, ga_White, ga_6, ga_2 );
  114.     ::InsetRect( &inFrame, 1, 1 );
  115.     PaintRect( inFrame, ga_Background );
  116. }
  117.  
  118. void    CGATextFieldAttachment::DrawColor( Rect &inFrame )
  119. {
  120.     EraseRect( inFrame, ga_White );
  121.     ::InsetRect( &inFrame, -1, -1 );
  122.     FrameRect( inFrame, ga_5, ga_White, ga_Background );
  123. }
  124.